#!/usr/bin/env python

from httputil import HttpUtil
from config import logger

class Snapshot(HttpUtil):
  def __init__(self, prefixURL=None):
    HttpUtil.__init__(self, prefixURL)

  def createSnapshot(self, volumeid):
    command = "createSnapshot"
    logger.debug("command=" + command)
    args = {"volumeid": volumeid}
    response = self.http_get(command, args=args, async=True)
    logger.debug(response)
    return response["snapshot"]

  def listSnapshots(self):
    command = "listSnapshots"
    logger.debug("command=" + command)
    response = self.http_get(command)
    logger.debug(response)
    return response


  def deleteSnapshot(self, snapshotid):
    command = "deleteSnapshot"
    logger.debug("command=" + command)
    args = {"id": snapshotid}
    response = self.http_get(command, args=args, async=True)
    logger.debug(response)
    return response

